//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using System.Collections;

namespace CommunityServer.Components
{
	/// <summary>
	/// The Favorites class is responsible for adding and retrieving
	/// favorites from a data store.
	/// </summary>
	public class Favorites
	{
		#region Constructors...
		/// <summary>
		/// Hide default constructor.
		/// </summary>
		private Favorites()
		{
		}
		#endregion

		#region Methods...
		/// <summary>
		/// Adds a favorite.
		/// </summary>
		/// <param name="favorite">The favorite to be added</param>
		/// <returns>The unique id for the added favorite</returns>
		public static int AddFavorite(Favorite favorite)
		{
			int favoriteID = CommonDataProvider.Instance().AddFavorite(favorite);
			CSEvents.FavoriteAdded(favorite, favorite.ApplicationType);
			return favoriteID;
		}


		/// <summary>
		/// Deletes a favorite.
		/// </summary>
		/// <param name="favoriteType"></param>
		/// <param name="favoriteID"></param>
		public static void DeleteFavorite(FavoriteType favoriteType, int favoriteID)
		{
			Favorite favorite = GetFavorite(favoriteType, favoriteID);
			CommonDataProvider.Instance().DeleteFavorite(favorite);
			CSEvents.FavoriteRemoved(favorite, favorite.ApplicationType);
		}


		/// <summary>
		/// Deletes a favorite.
		/// </summary>
		/// <param name="favoriteType"></param>
		/// <param name="userID"></param>
		/// <param name="itemID"></param>
		public static void DeleteFavorite(FavoriteType favoriteType, int userID, int itemID)
		{
			Favorite favorite = GetFavorite(favoriteType, userID, itemID);
			CommonDataProvider.Instance().DeleteFavorite(favorite);
			CSEvents.FavoriteRemoved(favorite, favorite.ApplicationType);
		}

		/// <summary>
		/// Retrieves a favorite.
		/// </summary>
		/// <param name="favoriteType">The type of favorite to return</param>
		/// <param name="favoriteID">The id of the favorite</param>
		/// <returns>The requested favorite</returns>
		public static Favorite GetFavorite(FavoriteType favoriteType, int favoriteID)
		{
			return CommonDataProvider.Instance().GetFavorite(favoriteType, favoriteID);
		}


		/// <summary>
		/// Retrieves a favorite.
		/// </summary>
		/// <param name="favoriteType"></param>
		/// <param name="userID"></param>
		/// <param name="itemID"></param>
		/// <returns></returns>
		public static Favorite GetFavorite(FavoriteType favoriteType, int userID, int itemID)
		{
			return CommonDataProvider.Instance().GetFavorite(favoriteType, userID, itemID);
		}

		/// <summary>
		/// Retrieves all favorites of a particular type for a user.
		/// </summary>
		/// <param name="favoriteType">The type of favorite to return</param>
		/// <param name="userID">The id of the user</param>
		/// <returns>The list of favorites</returns>
		public static IList GetFavorites(FavoriteType favoriteType, int userID)
		{
			return CommonDataProvider.Instance().GetFavorites(favoriteType, userID);
		}


		/// <summary>
		/// Retrieves a user's favorite posts.
		/// </summary>
		/// <param name="userID">The id of the favorite owner</param>
		/// <returns>A list of posts</returns>
		public static IList GetPosts(int userID)
		{
			return CommonDataProvider.Instance().GetFavoritePosts(userID);
		}


		/// <summary>
		/// Retrieves a user's favorite sections.
		/// </summary>
		/// <param name="userID">The id of the favorite owner</param>
		/// <returns>The list of sections</returns>
		public static IList GetSections(int userID)
		{
			return CommonDataProvider.Instance().GetFavoriteSections(userID);
		}


		/// <summary>
		/// Retrieves a user's favorite users.
		/// </summary>
		/// <param name="userID">The id of the favorite owner</param>
		/// <returns>A list of users</returns>
		public static IList GetUsers(int userID)
		{
			return CommonDataProvider.Instance().GetFavoriteUsers(userID);
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="userID"></param>
		/// <returns></returns>
		public static IList GetUsersWatching(int userID)
		{
			return CommonDataProvider.Instance().GetFavoriteUsersWatching(userID);
		}
		#endregion
	}
}
